﻿
function S0NodeLv1(option) {
    JzH5Node.call(this, option);
}

var myChart = null;
function closeChart() {
    if (myChart != null) {
        myChart.clear();
    }
}

function showChartWTSLD(title) {
    $.ajax({
        url: 'http://172.30.13.36:8080/api/wtsld/xy?name=order',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildChart(true, '委托受理单数', result.data.xValues, result.data.yValues);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function showWarnWTSLD(title) {
    var colors = ['rgb(0,70,231)','rgb(0,180,255)','rgb(4,246,255)','rgb(128,255,4)','rgb(255,172,4)'];
    $.ajax({
        url: 'http://172.30.13.36:8080/api/wtsld/xy?name=warn',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildBarChart(true, '异常信息Top', result.data.xValues, result.data.yValues, colors);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function showCustWTSLD(title) {
    $.ajax({
        url: 'http://172.30.13.36:8080/api/wtsld/xy?name=cust',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildWTSLDCustBarChart(true, '大客户VIP', result.data.xValues, result.data.yValues);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function showChartTG(title) {
    $.ajax({
        url: 'http://172.30.13.36:8080/api/tg/xy?name=order',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildChart(true, '通关', result.data.xValues, result.data.yValues);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function showChartZC(title) {
    $.ajax({
        url: 'http://172.30.13.36:8080/api/zc/xy?name=order',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildChart(true, '装船', result.data.xValues, result.data.yValues);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function showChartDG(title) {
    $.ajax({
        url: 'http://172.30.13.36:8080/api/dg/xy?name=order',
        type: 'GET',
        dataType: 'json',
        timeout: 60000,
        cache: false,
        beforeSend: function () {
        }, //加载执行方法
        error: function () {
            buildChart(false);
        },  //错误执行方法
        success: function (result) {
            if (result.isSuccess) {
                buildChart(true, '到港', result.data.xValues, result.data.yValues);
            } else {
                buildChart(false);
            }
        }//成功执行方法
    });
}

function buildChart(rebuild, title, xValues, yValues) {
    if (!rebuild) {
        return;
    }
    if (myChart != null) {
        myChart.clear();
    } else {
        var dom = document.getElementById("container");
        myChart = echarts.init(dom);
    }
    var app = {};
    option = null;
    option = {
        title: {
            text: title,
            show: true,
            textStyle: {
                color: '#fff'
            }
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            show: false,
            data: [title]
        },
        grid: {
            show: true,
            left: '0',
            right: '0',
            containLabel: false
        },
        xAxis: [{
            type: 'category',
            boundaryGap: false,
            data: xValues,
            axisLabel: {
                interval: 0,
                rotate: -45,
                textStyle: {
                    color: '#FFF'
                }
            },
            axisLine: {
                show: true
            },
            axisTick: {
                show: true
            }, splitLine: {
                show: true,
                interval: 0
            }
        }],
        yAxis: [
            {
                type: 'value',
                axisLabel: {
                    show: false
                },
                axisLine: {
                    show: true
                }, splitLine: {
                    show: true,
                    interval: 0
                }
            }
        ],
        series: [
            {
                name: title,
                type: 'line',
                stack: '总量',
                lineStyle: {
                    normal: {
                        color: 'rgb(255,240,0)',
                        width: 2,
                        type: 'solid'
                    }
                },
                areaStyle: {
                    normal: {

                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0, color: 'rgba(253,170,4,1)' // 0% 处的颜色
                        }, {
                            offset: 0.7, color: 'rgba(253,170,4, 0.6)' // 0% 处的颜色
                        }, {
                            offset: 1, color: 'rgba(0, 0, 0, 0.01)' // 100% 处的颜色
                        }], false)
                    }
                },
                data: yValues
            }
        ]
    };
    ;
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
}
function buildBarChart(rebuild, title, xValues, yValues, colors) {
    if (!rebuild) {
        return;
    }
    if (myChart != null) {
        myChart.clear();
    } else {
        var dom = document.getElementById("container");
        myChart = echarts.init(dom);
    }

    var datas = [];
    for (var index = 0; index < yValues.length; index++) {
        datas.push({
            name: index,
            value: yValues[index],
            itemStyle: {
                normal: {
                    color: colors[index]
                }
            }
        });
    }
    var app = {};
    option = {
        title: {
            text: title,
            show: true,
            textStyle: {
                color: '#fff'
            }
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            show:false,
            data: [title]
        },
        grid: {
            show: true,
            left: '20',
            right: '0',
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: xValues,
            axisLabel: {
                textStyle: {
                    color: '#FFF'
                }
            },
            axisLine: {
                show: true,
                onZero: false
            }
        }],
        yAxis: [
            {
                name: '(异常待处理量)',
                nameLocation: 'middle',
                nameTextStyle:{
                    color:'#fff'
                },
                nameGap:30,
                type: 'value',
                axisLabel: {
                    show: true,
                    textStyle: {
                        color:'#fff'
                    }
                },
                axisLine: {
                    show: true
                },
                splitLine: {
                    show: true,
                    interval: 0
                },
                axisTick: {
                    show:true
                }
            }
        ],
        series: [
            {
                name: title,
                type: 'bar',
                stack: '总量',
                barWidth:54,
                lineStyle: {
                    normal: {
                        color: 'rgb(255,240,0)',
                        width: 2,
                        type: 'solid'
                    }
                },
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0, color: 'rgba(253,170,4,1)' // 0% 处的颜色
                        }, {
                            offset: 0.7, color: 'rgba(253,170,4, 0.6)' // 0% 处的颜色
                        }, {
                            offset: 1, color: 'rgba(0, 0, 0, 0.01)' // 100% 处的颜色
                        }], false)
                    }
                },
                data: datas
            }
        ]
    };
    ;
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
}
function buildWTSLDCustBarChart(rebuild, title, xValues, yValues) {
    if (!rebuild) {
        return;
    }
    var colors = ['rgb(63,238,247)',
        'rgb(62,236,209)',
        'rgb(71,255,162)',
        'rgb(123,255,58)',
        'rgb(254,167,34)',
        'rgb(255,126,40)',
        'rgb(224,75,40)',
        'rgb(254,33,33)',
        'rgb(188,43,43)',
        'rgb(184,29,29)'];
    if (myChart != null) {
        myChart.clear();
    } else {
        var dom = document.getElementById("container");
        myChart = echarts.init(dom);
    }

    var datas = [];
    for (var index = 0; index < yValues.length; index++) {
        datas.push({
            name: index,
            value: yValues[index],
            itemStyle: {
                normal: {
                    color: colors[index]
                }
            }
        });
    }
    var app = {};
    option = {
        title: {
            text: title,
            show: true,
            textStyle: {
                color: '#fff'
            }
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            show: false,
            data: [title]
        },
        grid: {
            show: true,
            left: '0',
            right: '0',
            bottom:'0',
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: xValues,
            axisLabel: {
                show:false,
                interval:0,
                textStyle: {
                    color: '#FFF'
                },
                rotate:-80
            }
        }],
        yAxis: [
            {
                type: 'value',
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#fff'
                    }
                },
                axisLine: {
                    show: true
                },
                splitLine: {
                    show: true,
                    interval: 0
                },
                axisTick: {
                    show: true
                }
            }
        ],
        series: [
            {
                name: title,
                type: 'bar',
                stack: '总量',
                barWidth: 30,
                lineStyle: {
                    normal: {
                        color: 'rgb(255,240,0)',
                        width: 2,
                        type: 'solid'
                    }
                },
                areaStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0, color: 'rgba(253,170,4,1)' // 0% 处的颜色
                        }, {
                            offset: 0.7, color: 'rgba(253,170,4, 0.6)' // 0% 处的颜色
                        }, {
                            offset: 1, color: 'rgba(0, 0, 0, 0.01)' // 100% 处的颜色
                        }], false)
                    }
                },
                data: datas
            }
        ]
    };
    ;
    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }
}